var App = require("../../base/app");
var utils = require("../../utils/utils");
var common = require("./common");
var inTask = require("./inTask");
var aRead = require("./aRead");
var aEat1 = require("./aEat1");
var aEat2 = require("./aEat2");
var aEat3 = require("./aEat3");
var aEat4 = require("./aEat4");
var aWalk = require("./aWalk");
var aSleepGet = require("./aSleepGet");
var aSleep = require("./aSleep");
var aTreasure = require("./aTreasure");
var touTiao = new App("今日头条", {
  interval: 10,
  testOpenCount: 3,
  storage: common.storage,
});

touTiao.as = [
  aEat1,
  aEat2,
  aEat3,
  aEat4,
  aSleepGet,
  aSleep,
  aWalk,
];
touTiao.runTest = function () {
  common.toTask();
  sleep(utils.getRandom(5, 7, 1000));
};
touTiao.run = function () {
  aRead.flow();
  if (common.inHome()) {
    sleep(utils.getRandom(1.5, 2, 1000));
    common.toTask();
    sleep(utils.getRandom(5, 12, 1000));
    inTask.run();
    var nextAction = this.getNextAction();
    if (nextAction) {
      nextAction.flow();
    } else {
      aTreasure.flow();
    }
  }
};

module.exports = touTiao;
